﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_Object_Method
{
    internal class Program
    {
        static int count = 10; //static的使用
        static void Main(string[] args)
        {
            //Test1();
            //Test2();
            ShowContent1(1,new string[] { "AB","EF","CD","oc"});
            Console.WriteLine("------------");
            ShowContent2(2, new string[] { "11", "21", "3", "43" });
            Console.WriteLine("------------");
            ShowContent2(3,  "11", "21", "3", "43" );
            Console.WriteLine("------------");
            ShowContent3(3, "11", "21", "3", "43",66,77,9,"常老师");

            Console.ReadLine();
        }
        static void Test1()
        {
            //无参数构造方法
            Equipment equip = new Equipment();
            //有参数构造方法
            Equipment equip2 = new Equipment(3000,"空压机2组");
            Equipment equip3 = new Equipment(3000, "空压机2组","kyj.09");

            //使用对象初始化器
            Equipment equip4 = new Equipment
            {
                EquipId = 4000,
                EquipName = "测试设备组",
                EquipType = "cs001"
            };
            Equipment equip5 = new Equipment(2000, "空压机3组")
            {
                //SensorArray = new Sensor[5] //err 基础类型的只读属性里面可以赋值，外面不能赋值
                EquipType = "CS002"
            };
        }
        //构造方法测试
        //实例方法
        static void Test2()
        {
            Equipment equip = new Equipment();

            equip.ShowInfo();
            equip.ShowInfo("实验设备1",20.6);
            string result1 = equip.GetEquipStatus();
            string result2 = equip.GetEquipInfo("实验设备2", 12.3);
            Sensor sensor = equip.GetSensor(1);
            //Sensor[] sensorArray = equip.GetSensors(20.1);
            string result3 = equip.GetEquipInfo(200001, "实验设备3");
            string result4 = equip.GetEquipInfo(200001, "实验设备3",20.0);
            string result5 = equip.GetEquipInfo(pressure: 22.6, name: "实验设备3");

            //静态方法的调用
            string result6 = Equipment.GetStaticInfo("测试设备6");
            Console.WriteLine(result6);
        }
        static void ShowContent1(int num, string[] array)
        {
            Console.WriteLine($"第{num}个报文内容如下:");
            foreach(var item in array)
            {
                Console.WriteLine(item);
            }
        }
        static void ShowContent2(int num,params string[] array)
        {
            Console.WriteLine($"第{num}个报文内容如下:");
            foreach (var item in array)
            {
                Console.WriteLine(item);
            }
        }
        static void ShowContent3(int num, params object[] array)
        {
            Console.WriteLine($"第{num}个报文内容如下:");
            foreach (var item in array)
            {
                Console.WriteLine(item);
            }
        }
    }
}
